<html>
<head><meta charset="utf-8"><title>Option&lt;String&gt;, Option&lt;&amp;str&gt;, PartialEq,and pattern matching · t-lang · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/index.html">t-lang</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Option.3CString.3E.2C.20Option.3C.26str.3E.2C.20PartialEq.2Cand.20pattern.20matching.html">Option&lt;String&gt;, Option&lt;&amp;str&gt;, PartialEq,and pattern matching</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="187238663"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Option%3CString%3E%2C%20Option%3C%26str%3E%2C%20PartialEq%2Cand%20pattern%20matching/near/187238663" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Option.3CString.3E.2C.20Option.3C.26str.3E.2C.20PartialEq.2Cand.20pattern.20matching.html#187238663">(Feb 03 2020 at 07:02)</a>:</h4>
<p>I understand the reasons why we can't have a fully general <code>impl PartialEq&lt;Option&lt;RHS&gt;&gt; for Option&lt;LHS&gt; where LHS: PartialEq&lt;RHS&gt;</code>.<br>
But is there some <em>specific</em> reason we can't have the more specific <code>impl PartialEq&lt;Option&lt;&amp;str&gt;&gt; for Option&lt;String&gt;</code> and vice versa?</p>



<a name="187238681"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Option%3CString%3E%2C%20Option%3C%26str%3E%2C%20PartialEq%2Cand%20pattern%20matching/near/187238681" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Option.3CString.3E.2C.20Option.3C.26str.3E.2C.20PartialEq.2Cand.20pattern.20matching.html#187238681">(Feb 03 2020 at 07:03)</a>:</h4>
<p>Would even that narrow impl break backwards compatibility?</p>



<a name="187238690"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Option%3CString%3E%2C%20Option%3C%26str%3E%2C%20PartialEq%2Cand%20pattern%20matching/near/187238690" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Option.3CString.3E.2C.20Option.3C.26str.3E.2C.20PartialEq.2Cand.20pattern.20matching.html#187238690">(Feb 03 2020 at 07:03)</a>:</h4>
<p>(Or break too many existing programs even if type inference stability rules allow us to make that change?)</p>



<a name="187238739"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Option%3CString%3E%2C%20Option%3C%26str%3E%2C%20PartialEq%2Cand%20pattern%20matching/near/187238739" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Option.3CString.3E.2C.20Option.3C.26str.3E.2C.20PartialEq.2Cand.20pattern.20matching.html#187238739">(Feb 03 2020 at 07:04)</a>:</h4>
<p>Related: is there some fundamental reason we can't <code>match</code> an <code>Option&lt;String&gt;</code> against a pattern like <code>Some("foo")</code>, using a similar mechanism?</p>



<a name="187580323"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Option%3CString%3E%2C%20Option%3C%26str%3E%2C%20PartialEq%2Cand%20pattern%20matching/near/187580323" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Option.3CString.3E.2C.20Option.3C.26str.3E.2C.20PartialEq.2Cand.20pattern.20matching.html#187580323">(Feb 06 2020 at 19:30)</a>:</h4>
<p>Not sure about the former, but I don't think there's a fundamental reason we can't have the latter</p>



<a name="187580327"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Option%3CString%3E%2C%20Option%3C%26str%3E%2C%20PartialEq%2Cand%20pattern%20matching/near/187580327" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Option.3CString.3E.2C.20Option.3C.26str.3E.2C.20PartialEq.2Cand.20pattern.20matching.html#187580327">(Feb 06 2020 at 19:30)</a>:</h4>
<p>Apart from not having any such mechanism</p>



<a name="187580336"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Option%3CString%3E%2C%20Option%3C%26str%3E%2C%20PartialEq%2Cand%20pattern%20matching/near/187580336" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Option.3CString.3E.2C.20Option.3C.26str.3E.2C.20PartialEq.2Cand.20pattern.20matching.html#187580336">(Feb 06 2020 at 19:30)</a>:</h4>
<p>It might interact some with inference in corner cases</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>